<template>
  <div :class="className">
    <!-- style -->
    <div v-html="css"></div>
    <!-- 商品组 列表 -->
    <div class="u_grouplist" v-if="datas.preview_color">
      <div v-if="datas.list.length <= 0 && datas.goods_type === 'starGroup'" style="width: 100%;height: 150px;line-height: 50px;text-align: center;font-size: 18px"> <a-empty /> </div>
      <div class="u_grouplist_nav" v-if="datas.list">
        <div class="nav" v-if="datas.list.length > 0">
           <div class="nav-li">
            <div class="nav-lis nav-selected">全部拼团</div>
          </div>
          <div class="nav-li">
            <div class="nav-lis">积分参团</div>
          </div>
        </div>
      </div>
      <div class="u_grouplist_activity" v-if="datas.list.length > 0">
        <div class="activity" v-for="(item,index) in 2" :key="index">
          <div class="activity_title">
            <div>团长昵称</div>
            <div>活动名称活动名称</div>
          </div>
          <div class="right-box">
            <div class="activity_colonel">
              <div class="avatar" v-for="(img, i) in 4" :key="i"></div>
            </div>
            <div class="activity_btn">
              <div class="time-box">
                <div class="time" style="font-size: 16px;font-weight: bold">还差<span class="font-color">1人</span>拼成</div>
                <div class="time">距结束：00天07时21分09秒</div>
              </div>
              <div class="btn">立即参团</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import emptyImage from "@/resource/images/image.png";
// 自定义样式
const css = function() {
  if (this.datas.preview_color) {
    const {
      group_number,
      preview_color,
      tab_bgcolor,
      tab_color,
      tab_color_active,
      group_once_bg,
      group_once_color
    } = this.datas;
    return `
        .component-${this.id} .u_grouplist .activity{
            background-color: ${preview_color};
        }
        .component-${this.id}  .u_grouplist_nav {
          background-color: ${tab_bgcolor};
        }
        .component-${this.id}  .u_grouplist_nav .nav-li{
          color: ${tab_color};
        }
        .component-${this.id}  .u_grouplist_nav   .nav-selected{
            color: ${tab_color_active};
            border-bottom: 3px solid ${tab_color_active};
        }
        .component-${this.id} .activity_btn .btn{
          background-color: ${group_once_bg};
          color: ${group_once_color};
        }
        .component-${this.id} .u_grouplist .activity .font-color {
          color: ${group_once_bg};
        }
    `;
  }
};

export default {
  data() {
    return {
      emptyImage,
    };
  },
  props: ["id", "datas", "styles", "languages"],
  computed: {
    css() {
      return "<style>" + css.call(this) + "</style>";
    },
    className() {
      const name = ["component-wrapper", `component-${this.id}`];
      return name;
    },
    env() {
      return this.$store.state.page.env;
    },
  },
  methods: {
  },
  mounted() {

    this.$emit("loaded");
  }
};
</script>

<style lang="less" scoped>
// 默认
.component-wrapper {
  /*display: flex;*/
  /*justify-content: center;*/
  width: 375px;
}

.u_grouplist {
  padding-bottom: 10px;
  background-color:  #f2f2f2;
  width: 100%;
  .u_grouplist_nav {
    .nav {
      display: flex;
      align-items: center;
      height: 40px;
      white-space: nowrap;
      flex-wrap: nowrap;
      box-sizing: content-box;
      .nav-li {
        flex: 1;
        min-width: 20%;
        text-align: center;
        .nav-lis {
          display: inline-block;
          line-height: 40px;
        }
      }
    }
  }
  .u_grouplist_activity {
    .activity {
      padding: 15px;
      box-sizing: border-box;
      margin-bottom: 10px;
      .activity_title {
        padding-bottom: 10px;
        display: flex;
        justify-content: space-between;
        font-weight: bold;
        border-bottom: solid 1px #eeeeee;
      }
      .right-box {
        margin-top: 10px;
        display: flex;
        align-items: center;
      }
      .activity_colonel {
        display: flex;
        align-items: center;
        width: 116px;
        .avatar {
          width: 30px;
          height: 30px;
          background-color: #f2f2f2;
          border-radius: 50%;
          display: inline-block;
          margin-left: -5px;
          float: left;
        }
        .name {
          display: inline-block;
          margin-left: 8px;
        }
      }
      .activity_btn {
        flex: 1;
        /*margin-top: 20px;*/
        display: flex;
        justify-content: space-between;
        align-items: center;
        .time {
          font-size: 12px;
          text-align: right;
          color: #333333;
        }
        .btn {
          width: 75px;
          height: 35px;
          border-radius: 5px;
          display: flex;
          justify-content: center;
          align-items: center;

        }
      }
    }
    .activity:last-child {
      margin-bottom: 0;
    }
  }
}
.u_grouplist:last-child{
  padding-bottom: 0;
}
</style>
